package com.szxydb.dmp.admin.system.model;

import com.szxydb.dmp.utils.CrmebUtil;
import lombok.Data;

import java.io.Serializable;
import java.util.Locale;

@Data
public class TokenModel implements Serializable {

    public static final String TOKEN_KEY = "TOKEN";
    public static final String TOKEN_REDIS = "TOKEN_ADMIN_";
    private String userNo;
    private Integer userId;
    private String Token;
    private long lastAccessedTime = System.currentTimeMillis();
    private long expirationTime;
    private String clienttype;
    private Locale locale;
    private String host;
    private SystemAdmin systemAdmin;

    public String getAuthorization() throws Exception{
        return CrmebUtil.encryptPassword(userNo+"_"+Token,TOKEN_KEY);
    }

    public TokenModel(String userno,String token){
        this.userNo = userno;
        this.Token = token;
    }

    public TokenModel(){

    }
}
